#include "head.h"
#include <stdio.h>


int main(){

    int socket_fd;
    char* port = "8080";
    char* ip = "192.168.131.128";
    init_tcp(&socket_fd,port,ip);


    char* now_path = "~/";
    int is_login = 0;

    while(1){

        if(is_login == 0){
            user_system(socket_fd);
        }
        
        printf("user@%s --> :",now_path);
        fflush(stdout);
        sleep(1);


        char command[60]={0};
        fgets(command,sizeof(command),stdin);
        int comm_len = strlen(command);
        send(socket_fd,&comm_len,sizeof(int),0);
        send(socket_fd,command,comm_len,0);

        int sig;
        recv(socket_fd,&sig,sizeof(int),0);
        if(sig == ERROR){
            continue;
        }
        do_command(socket_fd,sig,now_path);

    }


    return 0;
}
